use "E:\Greg_Students\EmidyMichaelB\OrgJustice\JPART R&R Files\FEVES2012-15_Merged_NoDVs_12-21-20.dta"

egen nummiss1 = rowmiss(q17 q37 q38) // *Procedural Justice (alpha .83)
egen projust = rmean(q17 q37 q38) if nummiss1<2

egen nummiss2 = rowmiss(q22 q23 q24 q25 q31 q32 q33) // *Distributive Justice or Merit (.93)
egen distjust = rmean(q22 q23 q24 q25 q31 q32 q33) if nummiss2<3 

egen nummiss4 = rowmiss(q42 q43 q44 q45 q46 q47 q48 q49 q51) // *Perceptions of Supervisor (.96)
egen superjust = rmean(q42 q43 q44 q45 q46 q47 q48 q49 q51) if nummiss4<4 

egen nummiss8 = rowmiss(q20 q26 q27 q28) // *Relationship w/ Coworkers (.79)
egen people = rmean(q20 q26 q27 q28) if nummiss8<2 

egen nummiss5 = rowmiss(q54 q55 q56 q58 q61 q62 q66) // *Perceptions of Senior Leadership (.93)
egen orgjust = rmean(q54 q55 q56 q58 q61 q62 q66) if nummiss5<2 

egen nummiss6 = rowmiss(q63 q64 q65 q67 q69 q71) // *Job Satisfaction (.92)
egen jobsat = rmean(q63 q64 q65 q67 q69 q71) if nummiss6<2 

egen nummiss7 = rowmiss(q4 q5 q6 q12 q13 q30 q40) // *Affective Commitment (.87)
egen affcomm = rmean(q4 q5 q6 q12 q13 q30 q40) if nummiss7<3

label define agegrp 1 "Under 26" 2 "26-29" 3 "30-39" 4 "40-49" 5 "50-59" 6 "60 or older", replace

gen lgbna = .
replace lgbna = 1 if (lgbt == 1)
replace lgbna = 0 if (lgbt == 0)
replace lgbna = 2 if (lgbt == 2)
replace lgbna = 2 if (sexor1 == 3)
replace lgbna = 2 if (sexor1 == 4)
replace lgbna = 2 if (sexor1 == 8)
replace lgbna = 2 if (sexor1 == 9)
label define all3 0 "Heterosexual" 1 "LGB" 2 "Prefer Not to Say/No Answer"
label var lgbna "Sexual Orientation"
label val lgbna all3

gen lgb2 = . // *Making variable that drops Don't Know/Refused responses
replace lgb2 = 1 if (lgbna == 1)
replace lgb2 = 0 if (lgbna == 0)
label define dropped 0 "Heterosexual" 1 "LGB"
label var lgb2 "Sexual Orientation"
label val lgb2 dropped

gen intersect = racesex + (10*lgb2) // *Does not include Don't Know/Refused
label define int20 1 "White Hetero Female" 2 "Black Hetero Female" 3 "Asian Hetero Female" 4 "Other Hetero Female" ///
 5 "Hispanic Hetero Female" 6 "White Hetero Male" 7 "Black Hetero Male" 8 "Asian Hetero Male" 9 "Other Hetero Male" ///
 10 "Hispanic Hetero Male" 11 "White LGB Female" 12 "Black LGB Female" 13 "Asian LGB Female" 14 "Other LGB Female" ///
 15 "Hispanic LGB Female" 16 "White GB Male" 17 "Black GB Male" 18 "Asian GB Male" 19 "Other GB Male" ///
 20 "Hispanic GB Male" //
label var intersect "Race/Eth, Orientation, Sex"
label val intersect int20
tab intersect

replace location = 2 if (location==1) & (year==2012)
replace location = 1 if (location==0) & (year==2012)

tab races, gen(RACETH)
d RACETH*

gen male2 = male
replace male2 = 1 if (female==0)
replace male2 = 0 if (female==1)
tab male2

gen sexor2 = lgb2 + (2*male2)
label define orient4 0 "Heterosexual Female" 1 "LB Female" 2 "Heterosexual Male" 3 "GB Male"
label var sexor2 "Gender & Orientation"
label val sexor2 orient4
tab sexor2 male2

replace disability = 0 if (disability == 2)
label define YesNo1 0 "No" 1 "Yes"
label val disability YesNo1

tab year, sum(postwt)
gen wtx = postwt/2.7197567 if (year==2012)
replace wtx = postwt/4.7301086 if (year==2013)
replace wtx = postwt/4.5099721 if (year==2014)
replace wtx = postwt/4.1624732 if (year==2015)
tab year, sum(wtx)

mark ingram
markout ingram intersect disability agegrp fedten paycat super location AGCY year
keep if ingram==1

tab sexor1, gen(SEXOR)
d SEXOR*

tab intersect, gen(INTSEC)
d INTSEC*

replace agegrp = 2 if (agegrp==1)
tab agegrp, nol

gen racesexref = racesex
replace racesexref = 1 if (racesex == 6)
replace racesexref = 2 if (racesex == 7)
replace racesexref = 3 if (racesex == 8)
replace racesexref = 4 if (racesex == 9)
replace racesexref = 5 if (racesex == 10)
replace racesexref = 6 if (racesex == 1)
replace racesexref = 7 if (racesex == 2)
replace racesexref = 8 if (racesex == 3)
replace racesexref = 9 if (racesex == 4)
replace racesexref = 10 if (racesex == 5)
tab racesexref racesex

gen lgbint = lgb2
replace lgbint = 1 if (intersect==16)
replace lgbint = 2 if (intersect==17)
replace lgbint = 3 if (intersect==20)
replace lgbint = 4 if (intersect==18)
replace lgbint = 5 if (intersect==11)
replace lgbint = 6 if (intersect==12)
replace lgbint = 7 if (intersect==15)
replace lgbint = 8 if (intersect==13)
replace lgbint = 9 if (intersect==19)
replace lgbint = 10 if (intersect==14)
label var lgbint "Orientation/Race/Sex Interaction Terms"
label define lgbt8 1 "White Men" 2 "Black Men" 3 "Hispanic Men" 4 "Asian Men" ///
 5 "White Women" 6 "Black Women" 7 "Hispanic Women" 8 "Asian Women" //
label val lgbint lgbt8

replace ideo_rating = .02247123 if (AGCY==0)

mark mywords
markout mywords projust distjust
keep if mywords==1

gen femint = lgb2
replace femint = 1 if (sexor2==3)
replace femint = 2 if (sexor2==1)
tab male2 femint

** Panel A
reg projust i.femint i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.femint-1.femint
reg distjust i.femint i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.femint-1.femint
quietly reg superjust i.femint i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.femint-1.femint
quietly reg orgjust i.femint i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.femint-1.femint

gen ethint5 = lgb2
replace ethint5 = 1 if (lgb2==1) & (races==1)
replace ethint5 = 2 if (lgb2==1) & (races==2)
replace ethint5 = 3 if (lgb2==1) & (races==5)
replace ethint5 = 4 if (lgb2==1) & (races==3)
replace ethint5 = 5 if (lgb2==1) & (races==4)

** Panel B
reg projust i.ethint5 i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.ethint5-1.ethint5
lincom 3.ethint5-1.ethint5
lincom 4.ethint5-1.ethint5
reg distjust i.ethint5 i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.ethint5-1.ethint5
lincom 3.ethint5-1.ethint5
lincom 4.ethint5-1.ethint5
quietly reg superjust i.ethint5 i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.ethint5-1.ethint5
lincom 3.ethint5-1.ethint5
lincom 4.ethint5-1.ethint5
quietly reg orgjust i.ethint5 i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.ethint5-1.ethint5
lincom 3.ethint5-1.ethint5
lincom 4.ethint5-1.ethint5

** Panel C
reg projust i.lgbint i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 5.lgbint-1.lgbint
lincom 2.lgbint-1.lgbint
lincom 6.lgbint-5.lgbint
lincom 3.lgbint-1.lgbint
lincom 7.lgbint-5.lgbint
lincom 4.lgbint-1.lgbint
lincom 8.lgbint-5.lgbint
reg distjust i.lgbint i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 5.lgbint-1.lgbint
lincom 2.lgbint-1.lgbint
lincom 6.lgbint-5.lgbint
lincom 3.lgbint-1.lgbint
lincom 7.lgbint-5.lgbint
lincom 4.lgbint-1.lgbint
lincom 8.lgbint-5.lgbint
quietly reg superjust i.lgbint i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.lgbint-1.lgbint
lincom 3.lgbint-1.lgbint
lincom 5.lgbint-1.lgbint
lincom 7.lgbint-1.lgbint
lincom 4.lgbint-2.lgbint
lincom 6.lgbint-2.lgbint
lincom 8.lgbint-2.lgbint
quietly reg orgjust i.lgbint i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.lgbint-1.lgbint
lincom 3.lgbint-1.lgbint
lincom 5.lgbint-1.lgbint
lincom 7.lgbint-1.lgbint
lincom 4.lgbint-2.lgbint
lincom 6.lgbint-2.lgbint
lincom 8.lgbint-2.lgbint

gen disint = lgb2
replace disint = 1 if (sexor2==3) & (disability==0)
replace disint = 2 if (sexor2==3) & (disability==1)
replace disint = 3 if (sexor2==1) & (disability==0)
replace disint = 4 if (sexor2==1) & (disability==1)
tab disability disint

** Panel D
reg projust i.disint i.racesexref i.agegrp i.disability i.disfem i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.disint-1.disint
lincom 4.disint-3.disint
lincom (4.disint-3.disint)-(2.disint-1.disint)
reg distjust i.disint i.racesexref i.agegrp i.disability i.disfem i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.disint-1.disint
lincom 4.disint-3.disint
lincom (4.disint-3.disint)-(2.disint-1.disint)
quietly reg superjust i.disint i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.disint-1.disint
lincom 4.disint-3.disint
lincom (4.disint-3.disint)-(2.disint-1.disint)
quietly reg orgjust i.disint i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.disint-1.disint
lincom 4.disint-3.disint
lincom (4.disint-3.disint)-(2.disint-1.disint)

gen disfem = 0
replace disfem = 1 if (disability==1) & (male2==0)
tab disfem

gen biint = sexor1
replace biint = 0 if (sexor1==5)
replace biint = 1 if (sexor1==6)
replace biint = 2 if (sexor1==7)
replace biint = 3 if (sexor1==1)
replace biint = 4 if (sexor1==2)
tab biint sexor1

** Panel E
reg projust i.biint i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.biint-1.biint
lincom 3.biint-1.biint
lincom 4.biint-1.biint
reg distjust i.biint i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.biint-1.biint
lincom 3.biint-1.biint
lincom 4.biint-1.biint
quietly reg superjust i.biint i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.biint-1.biint
lincom 3.biint-1.biint
lincom 4.biint-1.biint
quietly reg orgjust i.biint i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.biint-1.biint
lincom 3.biint-1.biint
lincom 4.biint-1.biint

gen payint2 = lgb2
replace payint2 = 1 if (lgb2==1) & (paycat==5)
replace payint2 = 2 if (lgb2==1) & (paycat==1)
replace payint2 = 3 if (lgb2==1) & (paycat==2)
replace payint2 = 4 if (lgb2==1) & (paycat==3)
replace payint2 = 5 if (lgb2==1) & (paycat==4)
tab paycat payint2

** Panel F
reg projust i.payint2 i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.payint2-1.payint2
lincom 3.payint2-1.payint2
lincom 4.payint2-1.payint2
lincom 5.payint2-1.payint2
reg distjust i.payint2 i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.payint2-1.payint2
lincom 3.payint2-1.payint2
lincom 4.payint2-1.payint2
lincom 5.payint2-1.payint2
quietly reg superjust i.payint2 i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.payint2-1.payint2
lincom 3.payint2-1.payint2
lincom 4.payint2-1.payint2
lincom 5.payint2-1.payint2
quietly reg orgjust i.payint2 i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.payint2-1.payint2
lincom 3.payint2-1.payint2
lincom 4.payint2-1.payint2
lincom 5.payint2-1.payint2

gen supint2 = lgb2
replace supint2 = 1 if (lgb2==1) & (super==1)
replace supint2 = 2 if (lgb2==1) & (super==2)
replace supint2 = 3 if (lgb2==1) & (super==3)

** Panel G
reg projust i.supint2 i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.supint2-1.supint2
lincom 3.supint2-1.supint2
reg distjust i.supint2 i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.supint2-1.supint2
lincom 3.supint2-1.supint2
quietly reg superjust i.supint2 i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.supint2-1.supint2
lincom 3.supint2-1.supint2
quietly reg orgjust i.supint2 i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.supint2-1.supint2
lincom 3.supint2-1.supint2

gen ageint = lgb2
replace ageint = 1 if (lgb2==1) & (agegrp==2)
replace ageint = 2 if (lgb2==1) & (agegrp==3)
replace ageint = 3 if (lgb2==1) & (agegrp==4)
replace ageint = 4 if (lgb2==1) & (agegrp==5)
replace ageint = 5 if (lgb2==1) & (agegrp==6)
tab agegrp ageint

** Panel H
reg projust i.ageint i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.ageint-1.ageint
lincom 3.ageint-1.ageint
lincom 4.ageint-1.ageint
lincom 5.ageint-1.ageint
reg distjust i.ageint i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.ageint-1.ageint
lincom 3.ageint-1.ageint
lincom 4.ageint-1.ageint
lincom 5.ageint-1.ageint
quietly reg superjust i.ageint i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.ageint-1.ageint
lincom 3.ageint-1.ageint
lincom 4.ageint-1.ageint
lincom 5.ageint-1.ageint
quietly reg orgjust i.ageint i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.ageint-1.ageint
lincom 3.ageint-1.ageint
lincom 4.ageint-1.ageint
lincom 5.ageint-1.ageint

gen yearint2 = lgb2
replace yearint2 = 1 if (lgb2==1) & (year==2012)
replace yearint2 = 2 if (lgb2==1) & (year==2013)
replace yearint2 = 3 if (lgb2==1) & (year==2014)
replace yearint2 = 4 if (lgb2==1) & (year==2015)
tab year yearint2

** Panel I
reg projust i.yearint2 i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.yearint2-1.yearint2
lincom 3.yearint2-1.yearint2
lincom 4.yearint2-1.yearint2
reg distjust i.yearint2 i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.yearint2-1.yearint2
lincom 3.yearint2-1.yearint2
lincom 4.yearint2-1.yearint2
quietly reg superjust i.yearint2 i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.yearint2-1.yearint2
lincom 3.yearint2-1.yearint2
lincom 4.yearint2-1.yearint2
quietly reg orgjust i.yearint2 i.racesexref i.agegrp i.disability i.fedten i.paycat i.super i.location i.AGCY i.year[aw=wtx], rob
lincom 2.yearint2-1.yearint2
lincom 3.yearint2-1.yearint2
lincom 4.yearint2-1.yearint2














